const appInstance = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navHeight: 0,
    noTabHeight: 0,
    editing: false,
    avaertUrl: "https://free.modao.cc/uploads4/images/2836/28365480/v2_pj9ezs.jpg",
    name: "张学友",
    schoolName: "苏州实验小学",
    tel: "13332323232",
    idCard: "xxxxxxxxxxxxxxxxxx",
    schoolYear: 2019,
    schoolTerm: "上"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    if (options.type == "add") {
      this.setData({
        avaertUrl: "",
        name: "",
        schoolName: "",
        tel: "",
        idCard: "",
        schoolYear: null,
        schoolTerm: "",
        editing: true
      })
    }
    this.setData({
      navHeight: appInstance.globalData.navHeight,
      noTabHeight: appInstance.globalData.noTabHeight,
    })
  },

  editFlag(e) {
    this.setData({
      editing: e.detail.editing || false
    })
  },

  formEdit(e) {
    this.setData(e.detail)
  },

  choseImg() {
    wx.chooseImage({
      count: 1,
      success: (res) => {
        if (res.errMsg == "chooseImage:ok") {
          this.setData({
            avaertUrl: res.tempFilePaths[0]
          })
        }
      }
    })
  }
})